package test_junit_shop.Customer;

import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select;
import util.BaseDriver;

/**
 * Created by CYH on 2018/2/05.
 * 门店-客户服务-零售客户-法人客户管理-增加删除
 */

public class AddLegalCustomer extends BaseDriver{

    private static AddLegalCustomer instance=new AddLegalCustomer();

    private AddLegalCustomer(){}

    public static AddLegalCustomer getInstance(){
        return instance;
    }

    public void addLegalCustomer() throws InterruptedException {
        Thread.sleep(2000);
        driver=driver.switchTo().frame(2);

        driver.findElement(By.cssSelector("button.btn.btn-sm.btn-outline.btn-primary")).click();

        Thread.sleep(2000);
        driver=driver.switchTo().frame(0);
        driver.findElement(By.name("name")).click();
        driver.findElement(By.name("name")).clear();
        driver.findElement(By.name("name")).sendKeys("aas");
        driver.findElement(By.id("phone")).click();
        driver.findElement(By.id("phone")).clear();
        driver.findElement(By.id("phone")).sendKeys("15084978662");
        driver.findElement(By.name("officePhone")).click();
        driver.findElement(By.name("officePhone")).clear();
        driver.findElement(By.name("officePhone")).sendKeys("077508265");
        driver.findElement(By.name("address")).click();
        driver.findElement(By.name("address")).clear();
        driver.findElement(By.name("address")).sendKeys("湖南");
        driver.findElement(By.name("fullName")).click();
        driver.findElement(By.name("fullName")).clear();
        driver.findElement(By.name("fullName")).sendKeys("测试");
        driver.findElement(By.name("shortName")).click();
        driver.findElement(By.name("shortName")).clear();
        driver.findElement(By.name("shortName")).sendKeys("测");
        driver.findElement(By.name("creditCode")).click();
        driver.findElement(By.name("creditCode")).clear();
        driver.findElement(By.name("creditCode")).sendKeys("0885");
        driver.findElement(By.id("vehiclesDetail0-vehicleNoFirstStr")).click();
        new Select(driver.findElement(By.id("vehiclesDetail0-vehicleNoFirstStr"))).selectByVisibleText("京");
        driver.findElement(By.cssSelector("#vehiclesDetail0-vehicleNoFirstStr > option[value=\"1\"]")).click();
        driver.findElement(By.id("vehiclesDetail0-vehicleNoSecondStr")).click();
        new Select(driver.findElement(By.id("vehiclesDetail0-vehicleNoSecondStr"))).selectByVisibleText("A");
        driver.findElement(By.cssSelector("#vehiclesDetail0-vehicleNoSecondStr > option[value=\"1\"]")).click();
        driver.findElement(By.name("vehiclesDetail[0].vehicleNoSuffixStr")).click();
        driver.findElement(By.name("vehiclesDetail[0].vehicleNoSuffixStr")).clear();
        driver.findElement(By.name("vehiclesDetail[0].vehicleNoSuffixStr")).sendKeys("0775");
        driver.findElement(By.name("vehiclesDetail[0].vin")).click();
        driver.findElement(By.name("vehiclesDetail[0].vin")).clear();
        driver.findElement(By.name("vehiclesDetail[0].vin")).sendKeys("56541254563654896");
        driver.findElement(By.id("brand0")).click();
        new Select(driver.findElement(By.id("brand0"))).selectByVisibleText("AC Schnitzer");
        driver.findElement(By.cssSelector("option[value=\"290\"]")).click();
        driver.findElement(By.id("series0")).click();
        new Select(driver.findElement(By.id("series0"))).selectByVisibleText("AC Schnitzer M3");
        driver.findElement(By.cssSelector("option[value=\"2708\"]")).click();
        driver.findElement(By.id("style0")).click();
        new Select(driver.findElement(By.id("style0"))).selectByVisibleText("2015款 ACS3 sport");
        driver.findElement(By.cssSelector("option[value=\"33859\"]")).click();
        driver.findElement(By.id("saleConsultant-id")).click();
        new Select(driver.findElement(By.id("saleConsultant-id"))).selectByVisibleText("iii");
        driver.findElement(By.cssSelector("option[value=\"92\"]")).click();
        driver=driver.switchTo().parentFrame();
        driver.findElement(By.linkText("确定")).click();
    }

    public void deleteLegalCustomer() throws InterruptedException {
        Thread.sleep(2000);
        driver.findElement(By.name("btSelectItem")).click();
        driver.findElement(By.cssSelector("button.btn.btn-sm.btn-outline.btn-danger")).click();
        driver.findElement(By.linkText("确定")).click();
    }



}
